/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Controller;

import Entity.*;
import View.*;
import static java.lang.Thread.sleep;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import zaire.PhoneMap;

/**
 *
 * @author federicosanchi
 */
public class firstTry {
    
    private int panelWidth;
    private int panelHeight;
    private List<Phone> list;

    public void go(int cycles, int agents) {
        //take boundaries
        panelWidth = Pnl_Ground.getInstance().getWidth();
        panelHeight = Pnl_Ground.getInstance().getHeight();
        
        list = new ArrayList();
        
        this.init(agents);
        
        //this.trip(cycles);
        
        //via alle telefonate
        for(int i = 0; i < cycles; i++){
            
        }
        
    }

    private void init(int agents) {
        PhoneMap.getInstance().resetPhoneList();
        //creazione telefoni
        for(int i = 0; i < agents; i++){
            PhoneMap.getInstance().addPhone(new Phone());
            System.out.print("\nInit Agent" + i);
        }
        
        //creazione rubriche
        PhoneMap.getInstance().fillPhoneLists(0.5);
        
        
        Pnl_Ground.getInstance().repaint();
        
    }

    private void trip(int cycles) {
        for(int i = 0; i < cycles; i++){
            try {
                for(int j = 0; j < PhoneMap.getInstance().getPhoneListSize(); j++){
                    PhoneMap.getInstance().getPhone(j).muoviRandom();
                    //System.out.print("\nSpostamento agente turno " + i + " telefono " + j);
                }
                Thread.sleep(20);
            } catch (Exception ex) {
                Logger.getLogger(firstTry.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
}
